<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="/layout/template.xhtml">

<ui:define name="body">

    <h:form id="userSearch" styleClass="edit">

        <rich:simpleTogglePanel label="User Search Filter" switchType="ajax">

            <s:decorate template="/layout/display.xhtml">
                <ui:define name="label">Login</ui:define>
                <h:inputText id="login" value="#{usersBean.user.login}"/>
            </s:decorate>

            <s:decorate template="/layout/display.xhtml">
                <ui:define name="label">Password</ui:define>
                <h:inputText id="password" value="#{usersBean.user.password}"/>
            </s:decorate>

            <s:decorate template="/layout/display.xhtml">
                <ui:define name="label">Name</ui:define>
                <h:inputText id="name" value="#{usersBean.user.name}"/>
            </s:decorate>

            <s:decorate template="/layout/display.xhtml">
                <ui:define name="label">Surname</ui:define>
                <h:inputText id="surname" value="#{usersBean.user.surname}"/>
            </s:decorate>

            <s:decorate template="/layout/display.xhtml">
                <ui:define name="label">Type</ui:define>
                <h:inputText id="type" value="#{usersBean.user.type}"/>
            </s:decorate>

            <s:decorate template="/layout/display.xhtml">
                <ui:define name="label">Match</ui:define>
                <h:selectOneRadio id="logic" value="#{usersBean.restrictionLogicOperator}" styleClass="radio">
                    <f:selectItem itemLabel="All" itemValue="and"/>
                    <f:selectItem itemLabel="Any" itemValue="or"/>
                </h:selectOneRadio>
            </s:decorate>

        </rich:simpleTogglePanel>

        <div class="actionButtons">
            <h:commandButton id="search" value="Search" action="/acab/user/Users.xhtml"/>
            <s:button id="reset" value="Reset" includePageParams="false"/>
        </div>

    </h:form>

    <rich:panel>
        <f:facet name="header">User Search Results (#{empty usersBean.resultList ? 0 : (usersBean.paginated ? usersBean.resultCount : usersBean.resultList.size)})</f:facet>
    <div class="results" id="usersBean">

    <h:outputText value="The user search returned no results."
               rendered="#{empty usersBean.resultList}"/>

    <rich:dataTable id="usersBean"
                var="_user"
              value="#{usersBean.resultList}"
           rendered="#{not empty usersBean.resultList}">
 
        <h:column>
            <f:facet name="header">
                <ui:include src="/layout/sort.xhtml">
                    <ui:param name="entityList" value="#{usersBean}"/>
                    <ui:param name="propertyLabel" value="Login"/>
                    <ui:param name="propertyPath" value="user.login"/>
                </ui:include>
            </f:facet>


            <s:link view="/acab/user/UserDetails.xhtml"
             propagation="#{empty from ? 'none' : 'default'}"
                      id="userViewId">
				<f:param name="userIdUser" value="#{_user.idUser}"/>
            
 			<s:div styleClass="acab_user_name">
        		<s:graphicImage value="#{avatarManager.getUsersAvatarByType(_user, 'SMALL')}" rendered="#{avatarManager.getUsersAvatarByType(_user, 'SMALL')!= null}" fileName="#{_user.idUser}"  height="22"/>
        		<s:graphicImage value="/img/icons/no_avatar.jpg" rendered="#{avatarManager.getUsersAvatarByType(_user, 'SMALL')== null}" fileName="default"  height="22"/>
        		<br/>
        		<h:outputText value="#{_user.login}"/>
        	</s:div>           
            </s:link>
            
            
            
        </h:column>

        <h:column>
            <f:facet name="header">
                <ui:include src="/layout/sort.xhtml">
                    <ui:param name="entityList" value="#{usersBean}"/>
                    <ui:param name="propertyLabel" value="Name"/>
                    <ui:param name="propertyPath" value="user.name"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_user.name}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="/layout/sort.xhtml">
                    <ui:param name="entityList" value="#{usersBean}"/>
                    <ui:param name="propertyLabel" value="Surname"/>
                    <ui:param name="propertyPath" value="user.surname"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_user.surname}"/>
        </h:column>

        
        <h:column>
            <f:facet name="header">
                <ui:include src="/layout/sort.xhtml">
                    <ui:param name="entityList" value="#{usersBean}"/>
                    <ui:param name="propertyLabel" value="Calculated rate"/>
                    <ui:param name="propertyPath" value="user.calculatedRate"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_user.calculatedRate}"/>
        </h:column>
        
        <rich:column styleClass="action">
            <f:facet name="header">Travels</f:facet>
            <s:link view="/acab/travel/FindTravels.xhtml"
             propagation="#{empty from ? 'none' : 'default'}"
                      id="userTravelsId">
				<f:param name="idUser" value="#{_user.idUser}"/>
               	<s:graphicImage value="/img/icons/car_black.gif"  height="22"/>
            </s:link>
            
        </rich:column>
    </rich:dataTable>

    </div>
    </rich:panel>

    <div class="tableControl">

        <s:link view="/acab/user/Users.xhtml"
            rendered="#{usersBean.previousExists}"
               value="#{messages.left}#{messages.left} First Page"
                  id="firstPage">
          <f:param name="firstResult" value="0"/>
        </s:link>

        <s:link view="/acab/user/Users.xhtml"
            rendered="#{usersBean.previousExists}"
               value="#{messages.left} Previous Page"
                  id="previousPage">
            <f:param name="firstResult"
                    value="#{usersBean.previousFirstResult}"/>
        </s:link>

        <s:link view="/acab/user/Users.xhtml"
            rendered="#{usersBean.nextExists}"
               value="Next Page #{messages.right}"
                  id="nextPage">
            <f:param name="firstResult"
                    value="#{usersBean.nextFirstResult}"/>
        </s:link>

        <s:link view="/acab/user/Users.xhtml"
            rendered="#{usersBean.nextExists}"
               value="Last Page #{messages.right}#{messages.right}"
                  id="lastPage">
            <f:param name="firstResult"
                    value="#{usersBean.lastFirstResult}"/>
        </s:link>

    </div>

</ui:define>

</ui:composition>
